package vip.dulaogou.park;

import java.util.Objects;

/**
 * @author  duyouwei
 * @create  2021/4/19 13:26
 * @description
 * 汽车类
 *
 **/
public class Car {
    private String carId;   /*车牌号*/
    private EnterRecord enterRecord;   /*当前车子下对应的入库记录，只有停入车库的车才有，不然是null*/

    public Car(String carId) {
        this.carId = carId;
        enterRecord = null;
    }

    public String getCarId() {
        return carId;
    }

    public EnterRecord getEnterRecord() {
        return enterRecord;
    }

    public void setEnterRecord(EnterRecord enterRecord) {
        this.enterRecord = enterRecord;
    }

    public void setCarId(String carId) {
        this.carId = carId;
    }

    @Override
    public String toString() {
        return "Car{" +
                "carId=" + carId +
                '}';
    }

    /*只要保证车牌号相同就能确认是同一个车*/
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Car car = (Car) o;
        return Objects.equals(carId, car.carId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(carId);
    }
}
